//
//  ReginstViewController.m
//  Chat
//
//  Created by mac on 16/7/6.
//  Copyright © 2016年 Earl. All rights reserved.
//

#import "ReginstViewController.h"

@interface ReginstViewController ()
@property (weak, nonatomic) IBOutlet UITextField *nameTF;
@property (weak, nonatomic) IBOutlet UITextField *pswTF;
@property (weak, nonatomic) IBOutlet UITextField *surePswTF;
@property (weak, nonatomic) IBOutlet UITextField *nichengTF;
@property (weak, nonatomic) IBOutlet UITextField *emailTF;

@end

@implementation ReginstViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.navigationItem.title=@"注册";
    
}

- (IBAction)loginFinish:(UIButton *)sender {
    
    AFHTTPSessionManager *mar=[NetTool getSessionManager];
    
    if (mar) {
         NSDictionary *dic=@{@"command":@"ST_R",@"name":self.nameTF.text,@"psw":self.pswTF.text,@"nickname":self.nichengTF.text,@"email":self.emailTF.text};
        [mar POST:[self getNormallnterfaceUrl] parameters:dic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
            
            NSLog(@"===%@",[[NSString alloc]initWithData:responseObject encoding:NSUTF8StringEncoding]);
    
            if (responseObject) {
                NSDictionary *resultDic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
                if ([resultDic[@"result"] isEqualToString:@"1"]) {
                    [Util showAlertWithMessage:REGISTER_SUCCESS confirmBlock:^{
                        [self.navigationController popViewControllerAnimated:YES];
                    }];
                }
            }else{
                
                [Util showAlertWithMessage:USER_HAD_REGISTER confirmBlock:^{
                    [self.nameTF becomeFirstResponder];
                }];
                
            }
   
   
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        [Util showAlertWithMessage:LOAD_FAIL confirmBlock:nil];
    }];
    }
    
}







- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
